<?php
namespace app\banquet\controller;
use app\AdminRest;


use app\banquet\model\AtvContent;

use think\App;


use think\facade\Db;


class AdminAtv extends AdminRest
{

    protected $model;

    protected $content_model;

    protected $record_model;

    public function __construct(App $app) {

        parent::__construct($app);

//        $this->model = new CarAtvList();

        $this->content_model = new AtvContent();

//        $this->record_model = new CarAtvRecord();

    }




    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:28
     * @功能说明:内容列表
     */
    public function contentList(){

        $input = $this->_param;

        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['status','>',-1];

        $data = $this->content_model->dataList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:28
     * @功能说明:内容列表
     */
    public function contentSelect(){

        $input = $this->_param;

        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['status','=',1];

        $data = $this->content_model->where($dis)->order('top desc,id desc')->select()->toArray();

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:28
     * @功能说明:详情
     */
    public function contentInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->content_model->dataInfo($dis);

        return $this->success($data);

    }

    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:29
     * @功能说明:添加活动详情
     */
    public function contentAdd(){

        $input = $this->_input;

        $input['uniacid']  = $this->_uniacid;

        $data = $this->content_model->dataAdd($input);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:29
     * @功能说明:编辑活动详情
     */
    public function contentUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']
        ];

//        if(isset($input['status'])&&in_array($input['status'],[-1,0])){
//
//            $find = $this->model->atvContentIng($input['id']);
//
//            if(!empty($find)){
//
//                $this->errorMsg('该内容正在被使用');
//            }
//
//        }

        $data = $this->content_model->dataUpdate($dis,$input);

        return $this->success($data);

    }

}
